#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f3f3f3f3f;
const int N=5e5+10,M=2e5+10;
mt19937 rnd(time(0));
int n,m,q;
int fa[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void merge(int u,int v){fa[find(u)]=find(v);}
set<int>st;
int fr[N],ed[N];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("destory.in","r",stdin);
	freopen("destory.out","w",stdout);
	cin >> n >>m >> q;
	for ( int i = 1 ; i <= n ; i++ )fa[i]=i;
	while(m--)
	{
		int u,v;cin >>u >> v;
		merge(u,v);
	}
	while(q--)
	{
		int l,r;cin >> l >> r;
		for ( int i = 1 ; i <= n ; i++ )fr[i]=0,ed[i]=n+1;
		for ( int i = r ; i >= l ; i-- )
			ed[find(i)]=i;
		int L=0;
		st.clear();
		for ( int i = 1 ; i <= n ; i++ )if(ed[i]!=n+1)L=max(L,ed[i]);
		for ( int i = l ; i < L ; i++ )fr[find(i)]=i;
		for ( int i = 1 ; i <= n ; i++ )if(fr[i])st.insert(fr[i]);
		int ans=inf;
		for ( int i = L ; i <= r ; i++ )
		{
			if(fr[find(i)])st.erase(fr[find(i)]);
			fr[find(i)]=i;st.insert(fr[find(i)]);
			ans=min(ans,i-*st.begin()+1);
		}
		cout << ans << endl;
	}
	return 0;
}
/*
5 2 5
2 2
4 1
1 1
1 1
2 5
4 5
3 5
*/

